import Vue from 'vue';
import iView from 'iview';
import VueRouter from 'vue-router';
import Routers from './router';
import Util from './libs/util';
import App from './App.vue';
import 'iview/dist/styles/iview.css';

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
axios.defaults.baseURL = "http://localhost:8081/gamble_web_war/"
//axios.defaults.baseURL = "http://47.91.221.24:8080/gamble-web/"
Vue.prototype.$http = axios
Vue.use(VueRouter);
Vue.use(iView);
Vue.use(ElementUI)

// 路由配置
const RouterConfig = {
  mode: 'hash',
  routes: Routers
};
const router = new VueRouter(RouterConfig);

router.beforeEach((to, from, next) => {
  iView.LoadingBar.start();
  Util.title(to.meta.title);
  next();
});

router.afterEach((to, from, next) => {
  iView.LoadingBar.finish();
  window.scrollTo(0, 0);
});
//挂载
new Vue({
  el: '#app',
  router: router,
  render: h => h(App)
});
